package com.zzsin.gtestreporter.report;

import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;

public class TestTask {

    private List<XMLReport> xmlReportList = new LinkedList<>();

    private String path = null;
    private String id = "";
    private long time = 0;
    private String timeStr = "";

    public TestTask(String path, String id, long time){
        this.path   = path;
        this.id     = id;
        this.time   = time;

        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        timeStr = simpleDateFormat.format(new Date(this.time));
    }

    public int parse(){
        File dir = new File(this.path);

        for(File f : dir.listFiles()){
            if(!f.isFile()){
                continue;
            }
            if(f.getName().endsWith(".xml")){
                XMLReport xmlReport = new XMLReport(f.getAbsolutePath());
                xmlReport.parse();
                xmlReportList.add(xmlReport);
            }
        }

        return 0;
    }

    public String getPath() {
        return path;
    }

    public void setPath(String path) {
        this.path = path;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public List<XMLReport> getXmlReportList() {
        return xmlReportList;
    }

    public void setXmlReportList(List<XMLReport> xmlReportList) {
        this.xmlReportList = xmlReportList;
    }

    public long getTime() {
        return time;
    }

    public void setTime(long time) {
        this.time = time;
    }

    public String getTimeStr() {
        return timeStr;
    }

    public void setTimeStr(String timeStr) {
        this.timeStr = timeStr;
    }
}
